package com.mrjy.live.controller;

import javax.annotation.Resource;
import javax.mail.Session;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.dto.ParamsDto;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.entity.WisInfo;
import com.mrjy.common.util.GlobalConstant;
import com.mrjy.live.bo.IWisInfoBo;



@Controller
@RequestMapping("live/wisinfo")
public class WisInfoController {
	@Resource
	private IWisInfoBo wisInfoBo;
	
	/**
	 * 插入老师所属的白板id
	 * @param session
	 * @param wisInfo
	 * @return
	 */
	@RequestMapping("/insert")
	@ResponseBody
	public Object insert(HttpSession session,WisInfo wisInfo) {	
		UserInfo userInfo = (UserInfo)session.getAttribute(GlobalConstant.USER_INFO);
		wisInfo.setTeacherId(userInfo.getId());
		String message="ok";
		try{
			wisInfoBo.insertWisInfo(wisInfo);
		}catch(Exception e){
			e.printStackTrace();
			message="error";
		}
		return message;
	}
	
	
	/**
	 * 查询老师是否已经创建所属白板Id
	 * @param session
	 * @return
	 */
	@RequestMapping("/query")
	@ResponseBody
	public Object query(HttpSession session) {
		UserInfo userInfo = (UserInfo)session.getAttribute(GlobalConstant.USER_INFO);		
		return wisInfoBo.queryWisInfo(userInfo.getId());
	}
	
	/**
	 * 获取在线人数
	 * @return
	 */
	@RequestMapping("/onlineUsers")
	@ResponseBody
	public Object onlineUsers(ParamsDto paramsDto){
		return wisInfoBo.onlineUsers(paramsDto); 		
	}
	
}
